package com.kelaite.procurement.repository;

import java.util.Date;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

import com.kelaite.procurement.entity.TCompany;
import com.kelaite.procurement.entity.TUser;

public interface UserRepository extends JpaRepository<TUser, Long>{
	
	public TUser findByUsername(String username);
	
	public TUser findByTCompanyAndIsCompanyAdmin(TCompany company, Integer isCompanyAdmin);
	
	public Long  countByTCompany(TCompany tCompany);
	
	@Transactional
	@Modifying
	@Query(value = "update t_user set real_name = ?1, mobile_phone = ?2, company_id = ?3, role_ids = ?4, gmt_update_time = ?5 where id = ?6", nativeQuery = true)
	public void updateChangeUser(String realName,String mobilePhone,
			Long companyId,String roleIds,Date gmtUpdateTime,Long id);

}
